# DP解法
# 读取输入
n = int(input())
a = [0] + list(map(int, input().split()))  # 序列，从1开始索引
# 初始化DP数组
dp = [0] * (n + 1)
dp[1] = 1
ans = 1
# 动态规划求解
for i in range(2, n + 1):
    max_len = 0
    for j in range(1, i):
        if dp[j] > max_len and a[j] < a[i]:
            max_len = dp[j]
        dp[i] = max_len + 1
        if dp[i] > ans:
            ans = dp[i]
# 输出结果
print(ans)
